/*
 * Copyright (c) 2020, China Mobile Communications Group Co.,Ltd.
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2020-12-07     cmcc       the first version
 */
#ifndef NINESKY_IMAGE_RECOGNITION_NS_IMAGE_RECOG_H_
#define NINESKY_IMAGE_RECOGNITION_NS_IMAGE_RECOG_H_

//base url
#define URL_FIRE_DETECT_RECOG "http://aiaas.cmri.cn:8080/ivr/v1/fire_detection?"
#define URL_MASK_DETECT_RECOG "http://aiaas.cmri.cn:8080/ivr/v1/mask?"
#define URL_VIOLATION_DETECT_RECOG "http://aiaas.cmri.cn:8080/ivr/v1/picture_violation?"
#define URL_OBJECT_DETECT_RECOG "http://aiaas.cmri.cn:8080/ivr/v1/object_detection?"

typedef struct
{
    float fire;   //probability of fire
    float nofire; //probability of no fire
} NS_Fire_Detection;

typedef struct
{
    int objectCount;    //count of object
    int *haveMask;      //mask or not of object
    char **coordinates; //coordinate of mask
} NS_Mask_Detection;

typedef struct
{
    int noviolation; //no violation
} NS_Violation_Detection;

typedef struct
{
    int objectLabel;
    float score;
    float xmax;
    float xmin;
    float ymax;
    float ymin;
} NS_Object_detection_item;

typedef struct
{
    int objectCount;
    NS_Object_detection_item *items;
} NS_Object_detection;

/**
 * Fire detection.
 */
int ns_fire_detection(char *token, char *contentBuffer, long contentSize, NS_Fire_Detection *result);
int ns_fire_detection_file(char *token, char *filePath, NS_Fire_Detection *result);

/**
 * Mask detection.
 */
int ns_mask_detection(char *token, char *contentBuffer, long contentSize, NS_Mask_Detection *result);
int ns_mask_detection_file(char *token, char *filePath, NS_Mask_Detection *result);

/**
 * Image violation detection.
 */
int ns_violation_detection(char *token, char *contentBuffer, long contentSize, NS_Violation_Detection *result);
int ns_violation_detection_file(char *token, char *filePath, NS_Violation_Detection *result);

/**
 * Object detection.
 */
int ns_object_detection(char *token, char *contentBuffer, long contentSize, NS_Object_detection *result);
int ns_object_detection_file(char *token, char *filePath, NS_Object_detection *result);

#endif /* NINESKY_IMAGE_RECOGNITION_NS_IMAGE_RECOG_H_ */
